/*
 * @Author: 鸿羽飞舟 2653235481@qq.com
 * @Date: 2022-08-19 09:03:23
 * @LastEditors: 鸿羽飞舟 2653235481@qq.com
 * @LastEditTime: 2022-08-19 09:06:51
 * @FilePath: \学习笔记-1c:\Users\zhongyuhong\Documents\Tencent Files\2653235481\FileRecv\实训三\js刷题\01.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
var addTwoNumbers = function(l1, l2) {
    var a=l1.length>l2.length?l1.length:l2.length;
    var b=new Array(a);
    b[0]=0;
    for(var i=0;i<a;i++){
        if(l1[i]==undefined){
            console.log(b[i]);
            b[i]+=l2[i];
            console.log(b[i],i);
        }else if(l2[i]==undefined){
            b[i]+=l1[i];
        }else{
            b[i]+=l1[i]+l2[i];
            if(b[i]>9){
                b[i]=b[i]%10;
                b[i+1]=1;
            }else if(i<a-1){
                b[i+1]=0;
            }
        }
    }
    return b
};
var l1 = [6,4,7], l2 = [5,6,4];
console.log(addTwoNumbers(l1,l2));